{	Problem: http://codeforces.ru/problemset/problem/5/B
	Verdict: Accepted
}
var a:array[1..1010] of string; i,n,m,k:longint; f:boolean;
function sp(n:longint):string;
var i:longint;
begin
result:='';
for i:=1 to n do result:=result+' ';
end;
begin
n:=0;
m:=0;
while not eof do begin
    inc(n);
    readln(a[n]);
    if length(a[n])>m then m:=length(a[n]);
end;
for i:=1 to m+2 do write('*');
writeln;
f:=false;
for i:=1 to n do begin
    write('*');
    k:=m-length(a[i]);
    if odd(k) and f then write(sp(k div 2+1)) else 
    if odd(k) and (not f) then write(sp(k div 2)) else
    if not odd(k) then write(sp(k div 2));
    write(a[i]);
    if odd(k) and f then begin
        write(sp(k div 2));
        f:=false;
    end else 
    if odd(k) and (not f) then begin
        write(sp(k div 2+1));
        f:=true;
    end else
    if not odd(k) then write(sp(k div 2));
    writeln('*');
end;
for i:=1 to m+2 do write('*');
writeln;
end.